package com.bdqn.service;

import com.bdqn.dao.UserDao;
import com.bdqn.pojo.User;
import org.apache.log4j.Logger;

/**
 * UserServiceImpl
 *
 * @author LILIBO
 * @since 2021-12-09
 */
public class UserServiceImpl implements UserService {

    private Logger logger = Logger.getLogger(UserServiceImpl.class);

    private UserDao userDao;

    /**
     * set方法给Spring注入
     *
     * @param userDao
     */
    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    @Override
    public void save(User user) {
        int n = 1 / 0; // 模拟抛出一个除数不能为零的异常
        int row = userDao.save(user);
        logger.debug("调用Dao层方法保存数据成功，受影响的行数是：" + row);
        // return row;
    }

}
